<%--
  Created by IntelliJ IDEA.
  User: 494418174
  Date: 2020/3/6 0006
  Time: 15:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/favicon.ico">
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/layui_ext/dtree/dtree.css">
    <link rel="stylesheet" href="/layui_ext/dtree/font/dtreefont.css">
</head>
<body class="childrenBody">
<!-- 搜索条件开始 -->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>查询条件</legend>
</fieldset>
<form class="layui-form" method="post" id="searchFrm">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">订单号:</label>
            <div class="layui-input-inline" style="padding: 5px">
                <input type="text" name="rentId" id="rentId" autocomplete="off" class="layui-input layui-input-inline"
                       placeholder="请输入订单号" style="height: 30px;border-radius: 10px">
            </div>
        </div>
        <div class="layui-inline">
            <button type="button"
                    class="layui-btn layui-btn-normal layui-icon layui-icon-search layui-btn-radius layui-btn-sm"
                    lay-submit lay-filter="formDemo" style="margin-top: 4px">查询
            </button>
            <button type="reset"
                    class="layui-btn layui-btn-warm layui-icon layui-icon-refresh layui-btn-radius layui-btn-sm"
                    style="margin-top: 4px">重置
            </button>
        </div>
    </div>

</form>

<!-- 搜索条件结束 -->



<!-- 添加和修改的弹出层-->
<div id="content" style="display: none" lay-filter="content">
    <blockquote class="layui-elem-quote" style="margin-top: 10px">
        <div id="test2">
            检查单表单
        </div>
    </blockquote>
    <form class="layui-form" method="post" id="checkFrm" lay-filter="checkFrm">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">检查单号:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="checkId" readonly="readonly"
                           class="layui-input layui-input-inline"
                           placeholder="请输入检查单号" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">出租单号:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="rentId" id="rentId2" readonly="readonly" autocomplete="off"
                           class="layui-input layui-input-inline"
                           placeholder="请输入出租单号" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">操作员:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="openName" readonly="readonly" autocomplete="off"
                           class="layui-input layui-input-inline"
                           placeholder="请输入操作员" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">存在问题:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="problem" id="problem" required  lay-verify="required" autocomplete="off"
                           class="layui-input layui-input-inline"
                           placeholder="请输入存在的问题" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">赔付金额:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="payMoney" id="payMoney" required  lay-verify="required" autocomplete="off"
                           class="layui-input layui-input-inline"
                           placeholder="请输入赔付金额" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">检查时间:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="checkDate" id="checkDate" required  lay-verify="required"
                           class="layui-input layui-input-inline"
                           placeholder="请输入检查时间" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">问题描述:</label>
            <div class="layui-input-block">
                <textarea name="checkDesc" placeholder="请输入问题描述" required  lay-verify="required" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item" style="text-align: center">
            <button type="button" lay-submit="" lay-filter="doSubmit"
                    class="layui-btn layui-btn-normal layui-icon layui-icon-release layui-btn-radius layui-btn-sm"
                    lay-filter="doSubmit" lay-submit="" style="margin-top: 4px">保存
            </button>
        </div>
    </form>
    <%--出租单信息，车辆信息，客户信息的展示--%>
    <div style="padding: 10px; background-color: #F2F2F2;">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md4">
                <div class="layui-card">
                    <div class="layui-card-header">车辆信息</div>
                    <div class="layui-card-body" id="car_carNumber"></div>
                    <div class="layui-card-body" id="car_carType"></div>
                    <div class="layui-card-body" id="car_color"></div>
                    <div class="layui-card-body" id="car_price"></div>
                    <div class="layui-card-body" id="car_rentPrice"></div>
                    <div class="layui-card-body" id="car_deposit"></div>
                    <div class="layui-card-body" id="car_description"></div>
                    <div class="layui-card-body">
                        车辆图片：<img src="" width="200" height="150" id="car_carimg">
                    </div>
                </div>
            </div>
            <div class="layui-col-md4">
                <div class="layui-card">
                    <div class="layui-card-header">出租单信息</div>
                    <div class="layui-card-body" id="rent_rentId"></div>
                    <div class="layui-card-body" id="rent_price"></div>
                    <div class="layui-card-body" id="rent_beginDate"></div>
                    <div class="layui-card-body" id="rent_returnDate"></div>
                    <div class="layui-card-body" id="rent_openName"></div>
                </div>
            </div>
            <div class="layui-col-md4">
                <div class="layui-card">
                    <div class="layui-card-header">客户信息</div>
                    <div class="layui-card-body" id="customer_identity"></div>
                    <div class="layui-card-body" id="customer_custName"></div>
                    <div class="layui-card-body" id="customer_sex"></div>
                    <div class="layui-card-body" id="customer_address"></div>
                    <div class="layui-card-body" id="customer_phone"></div>
                    <div class="layui-card-body" id="customer_career"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<%-- 添加或者修改弹出框结束 --%>

<script src="/layui/layui.js"></script>
<script>
    var carTable
    var index
    var url
    var uploadImg
    layui.extend({
        dtree: '/layui_ext/dtree/dtree'   // {/}的意思即代表采用自有路径，即不跟随 base 路径
    }).use(['table','form','layer','jquery','dtree','upload','laydate'], function() {
        var table = layui.table
        var form = layui.form
        var layer = layui.layer
        var $ = layui.jquery
        var laydate=layui.laydate
        // 初始table
        function initCarTable(){

        }

        // 查询
        form.on("submit(formDemo)", function () {
            $.post("/check/findCheck",{"rentId":$("#rentId").val()},function (re) {
                if(re.code==1){
                    $("#content").hide()
                    layer.msg(re.msg)
                }else {
                    if(re.data.rent.rentFlag=="1"){
                        layer.msg("该订单已经处理")
                    }else {
                        $("#content").show();
                        // 设置检查单信息
                        $('[name="checkId"]').val(re.data.checkId);
                        $('#rentId2').val($("#rentId").val())
                        $('[name="openName"]').val(re.data.openName)
                        $('#payMoney').val(0)
                        laydate.render({
                            elem: '#checkDate'
                            ,type : "datetime"
                            ,value:new Date()
                        });
                        // 设置车辆信息
                        var car = re.data.car
                        $("#car_carNumber").html("车辆编号："+car.carNumber);
                        $("#car_carType").html("车辆类型："+car.carType);
                        $("#car_color").html("车辆颜色："+car.color);
                        $("#car_price").html("车辆价格："+car.price);
                        $("#car_rentPrice").html("出租价格："+car.rentPrice);
                        $("#car_deposit").html("车辆押金："+car.deposit);
                        $("#car_description").html("车辆押金："+car.description);
                        $("#car_carimg").attr("src",car.carimg);

                        // 设置出租单信息
                        var rent = re.data.rent
                        $("#rent_rentId").html("出租单号："+ rent.rentId);
                        $("#rent_price").html("出租价格："+ rent.price);
                        $("#rent_beginDate").html("租车时间："+ rent.beginDate);
                        $("#rent_returnDate").html("还车时间："+ rent.returnDate);
                        $("#rent_openName").html("操作人："+ rent.openName);

                        // 设置客户信息
                        var customer = re.data.customer
                        $("#customer_identity").html("身份编号："+ customer.identity);
                        $("#customer_custName").html("客户姓名："+ customer.custName);
                        var sex = customer.sex=="1"?"男":"女"
                        $("#customer_sex").html("客户性别："+ sex);
                        $("#customer_address").html("客户住址："+ customer.address);
                        $("#customer_phone").html("联系方式："+ customer.phone);
                        $("#customer_career").html("职位："+ customer.career);

                    }


                }
            })
            return false;
        })


        // form表达提交 -- 新增/修改
        form.on("submit(doSubmit)",function() {
            layer.confirm("您确定要提交该数据么",function(ind){
                $.post("/check/addCheck",$("#checkFrm").serialize(),function(data) {
                    layer.msg(data.msg)
                    // 刷新table数据
                    $("#content").hide();
                    $("#rentId").val("")
                })
                layer.close(ind)
            })
            return false;
        })



    })

</script>
</body>
</html>
